package com.campus.web.controller.functional;

import com.campus.commons.utils.Result;
import com.campus.config.cache.Sign;
import com.campus.config.cache.SignInCache;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;

@RestController
@RequestMapping("/position")
public class PositionController {
    @PostMapping("/init")
    @ApiOperation("初始化签到信息")
    public Result Init() {
        return Result.result(SignInCache.init());
    }
    @PostMapping("/alter")
    @ApiOperation("改变签到地方；注意位置顺序左上，右上，右下，左下")
    public Result AlterRange(Double[] x, Double[] y) {
        return Result.result(SignInCache.calculationOfPosition.setXsAndYs(new ArrayList<Double>(Arrays.asList(x)),new ArrayList<Double>(Arrays.asList(y))));
    }
    @PostMapping("/signIn")
    @ApiOperation("签到方法;")
    public Result SignIn(Integer studentId, Double x, Double y) {
        return SignInCache.Sing(studentId, x, y);
    }

}
